realmcrafterfandomcom-20200216-history
Pet Follow Ability Script
Created by Taz. Using "RC_Core.rcm" ; By Tazco ;Make pet follow and attack leaders target. Function Main() Player = Actor() Target = ContextActor() PName$ = Name(Player) TName$ = Name(Target) ScriptLog("Pet follow running by " + Pname) ;------------------------------------------------------------------------------------------------ ;tamed pet follow. StoredTamedID% = Split(ActorGlobal(Player, 3), 21, "|") If (StoredTamedID > 0) ;Check Tamed Pet Health see if its still alive. TamedHP% = Attribute(StoredTamedID, "Health") If (TamedHP > 0) ;tamed npc is alive so kill it. SetActorAIState(StoredTamedID, 5) ;set pet to follow player Return Else OutPut(Player, "You dont have a pet out.", 255, 127, 21) Return Endif Endif ;End tamed pet follow. ;------------------------------------------------------------------------------------------------ PetID$ = ActorID("Gremlin", "") ;pet id Petname$ = "Gremlin" ;Pet Name PetFound% = 0 ;Used for repeat if = 1 end repeat ;Look for actor pet ;Repeat ;--------------------------------Vampire Check---------------------------------------------------------------------------------- ;If vamp dont tell player they cant use a pet in this form IsVamp% = ActorId("Vampire", "Form") PRace$ = Race(Player) PClass$ = Class(Player) PlayerID% =ActorID(PRace, PClass) If(IsVamp = PlayerID) ;if player is a vampire OutPut(Player, "You can not use a human pet in vampire form.", 255, 34, 12) Return EndIf ;----------------------------End Vampire Check---------------------------------------------------------------------------------- PetID$ = ActorID("Gremlin", "") ;pet id Petname$ = "Gremlin" ;Pet Name PetToFind$ = FindActor(Petname, 2) ;type 2 search through NPCs PetTag$ = Tag(PetToFind) NpcName$ = Name(PetToFind) ;found actor name PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name. FirstPet$ = PetTag ;Tag of first pet in zone found. ;Look for actor pet Repeat ;check if player has a pet already ;OutPut(Player, "Stored pet name " + PetOwnerName) If (PetOwnerName = Pname) EndRepeat% = 1 Else If Not (PetTag = + PName + "s Pet") ;If npc found is a gremlin pet PetToFind$ = NextActorInZone(PetToFind) NpcName$ = Name(PetToFind) ;found actor name PetTag$ = Tag(PetToFind) PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name. EndIf Endif DoEvents(14) Until (PetTag = + PName + "s Pet") or (PetTag = FirstPet) or (EndRepeat = 1) ;end if pet is out check If (NpcName = Petname) ;If npc found is a gremlin pet PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name. If (PetOwnerName = PName) ;see if pet found is players pet. Check stored name to player name. ;Incress speed NewSpeed2 = Attribute(PetToFind, "Speed") NewSpeed% = NewSpeed2 + 15 SetAttribute(PetToFind, "Speed", NewSpeed) SetActorAIState(PetToFind, 5) ;set pet to follow player ;Play random animation on wait command for pet. PickAni% = Rand(1, 2) If (PickAni = 1) AnimateActor(PetToFind, "Jumping Happy", .5, 2) DoEvents(2000) EndIf If (PickAni = 2) AnimateActor(PetToFind, "Laughing", .5, 2) DoEvents(2000) EndIf PetFound% = 1 EndIf EndIf DoEvents(10) If (PetOwnerName = "") PetFound% = 1 EndIf ;Until (PetFound = 1) ;end gremlin check PetID$ = ActorID("RockHead", "") ;pet id RockPetname$ = "RockHead" ;Pet Name PetFound% = 0 ;Used for repeat if = 1 end repeat ;Look for actor pet ;Repeat PetToFind$ = FindActor(RockPetname, 2) ;type 2 search through NPCs RockNpcName$ = Name(PetToFind) ;found actor name If (RockNpcName = RockPetname) ;If npc found is a gremlin pet PetOwnerName$ = ActorGlobal(PetToFind, 1) ;check for pet owner name. If (PetOwnerName = PName) ;see if pet found is players pet. Check stored name to player name. SetActorAIState(PetToFind, 5) ;set pet to follow player PetFound% = 1 EndIf EndIf DoEvents(10) If (PetOwnerName = "") PetFound% = 1 EndIf ;Until (PetFound = 1) ;end rockhead check If (PetOwnerName = "") OutPut(Player, "You must have a summoned pet, to use this ability.") Return EndIf AnimateActor(PetToFind, "Idle3", .5, 2) End Function